﻿using Shop.BLL;
using Shop.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Shop.MVC.Controllers
{
    public class HomeController : Controller
    {
        BaseManager<Category> cateManager = new BaseManager<Category>();
        BaseManager<Product> productManager = new BaseManager<Product>();
        BaseManager<Ad> adManager=new BaseManager<Ad>();

        public ActionResult Index()
        {
            // 读取商品类别
            ViewBag.Cate= cateManager.GetList();
            int count;
            ViewBag.Product= productManager.GetList("", null, 1, 6, out count);
            // 获取“热销部分”商品

            ViewBag.Ads = adManager.GetList();
            return View();
        }
        public ActionResult GetCategory()
        {
            var cates=cateManager.GetList();
            return Json(cates,JsonRequestBehavior.AllowGet);
        }
    }
}